//
//  CustomerInfoViewController.m
//  mendianjieke
//
//  Created by 响当当 on 7/31/19.
//  Copyright © 2019 dongzheng. All rights reserved.
//

#import "CustomerInfoViewController.h"
#import "CustomerInfoView.h"

@interface CustomerInfoViewController ()
@property (nonatomic, strong)CustomerInfoView *infoView;
@end

@implementation CustomerInfoViewController

- (CustomerInfoView *)infoView
{
    if (!_infoView)
    {
        _infoView = [[CustomerInfoView alloc]initWithFrame:CGRectMake(0,NAVIBAR_HEIGHT,SCREEN_WIDTH,SCREEN_HEIGHT-NAVIBAR_HEIGHT)];
    }
    return _infoView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setDefaultNavWithTitle:@"查看攻略"];
    self.viewType = 1;

    [self.view addSubview:self.infoView];
    
    [self getinfo];
    [self getCustomerInfo];
}

- (void)getinfo
{
    
    NSDictionary *pramaters = @{
                                @"id" : self.customerID
                                };
    
    WeakSelf(self)
    [infoManager getCustomerInfo:pramaters sucess:^(id  _Nonnull acceptData) {
        [weakSelf.infoView getInfo:acceptData];
        [weakSelf showNewUserGuideIfNeed];
    } fail:^(NSError * _Nullable error) {
        
    }];
}

- (void)getCustomerInfo
{
    
    NSDictionary *pramaters = @{
                                @"id" : self.customerID
                                };
    
    WeakSelf(self)
    [infoManager getCustomerAttackInfo:pramaters sucess:^(id  _Nonnull acceptData) {
        [weakSelf.infoView customerAttack:acceptData];

    } fail:^(NSError * _Nullable error) {
        
    }];
}


///新手引导,聚光灯
-(void)showNewUserGuideIfNeed
{
    ///先注释,方便查看效果
    if([NewUserGuide hadShowNewUserGuideForKey:@"stepFour"] || [NewUserGuide isShowingNewUserGuideForKey:@"stepFive"] || [NewUserGuide isShowingNewUserGuideForKey:@"stepSix"])
      {
          return;
      }
    
    UIView *onView ;
    
    onView = [UIApplication sharedApplication].keyWindow;
    
    CGRect cellFrame = CGRectMake(10*kUIScaleBasePlus,50*kUIScaleBasePlus+NAVIBAR_HEIGHT,SCREEN_WIDTH-20*kUIScaleBasePlus,200*kUIScaleBasePlus);
    
    CGRect expressionFrame = CGRectMake(5*kUIScaleBasePlus,230*kUIScaleBasePlus+NAVIBAR_HEIGHT,SCREEN_WIDTH-10*kUIScaleBasePlus,SCREEN_HEIGHT-200*kUIScaleBasePlus-NAVIBAR_HEIGHT);
    
     CGRect getFrame = CGRectMake(187*kUIScaleBasePlus,NAVIBAR_HEIGHT,187*kUIScaleBasePlus,45*kUIScaleBasePlus);
    
    
    UIBezierPath *cellPath = [UIBezierPath bezierPathWithRoundedRect:[self.view convertRect:cellFrame toView:onView] cornerRadius:5];
    UIImage *cellImage = [UIImage imageNamed:@"step_four"];
    
    UIBezierPath *expressionPath = [UIBezierPath bezierPathWithRoundedRect:[self.view convertRect:expressionFrame toView:onView] cornerRadius:5];
    UIImage *expressionImage = [UIImage imageNamed:@"step_five"];
    
    UIBezierPath *getPath = [UIBezierPath bezierPathWithRoundedRect:[self.view convertRect:getFrame toView:onView] cornerRadius:expressionFrame.size.height/2];
    UIImage *getImage = [UIImage imageNamed:@"step_six"];
      
    CGPoint cellPoint = CGPointMake(0,CGRectGetMaxY(cellFrame)+cellImage.size.height/2+30*kUIScaleBasePlus);
    
    CGPoint expressionPoint = CGPointMake(0,CGRectGetMinY(expressionFrame)-expressionImage.size.height);
    
    CGPoint getPoint = CGPointMake(0,CGRectGetMaxY(getFrame)+30*kUIScaleBasePlus);
    
    NewUserGuide *view = [[NewUserGuide alloc] init];
    
    [view showOn:onView path:cellPath appendPath:YES image:cellImage imageAt:cellPoint withKey:@"stepFour" afterTap:^{
        
        [view showOn:onView path:expressionPath appendPath:YES image:expressionImage imageAt:expressionPoint withKey:@"stepFive" afterTap:^{
            
               [view showOn:onView path:getPath appendPath:YES image:getImage imageAt:getPoint withKey:@"stepSix" afterTap:^{
                             
                             
                }];
               
           }];
        
    }];
    
}
@end
